import 'dart:convert';

import 'package:fluro/fluro.dart';
import 'package:talk/pages/my/model/UserModel.dart';
import 'package:talk/pages/my/user_about.dart';
import 'package:talk/pages/my/userInfo.dart';
import 'package:talk/pages/my/user_hide_auth.dart';
import 'package:talk/pages/my/user_system.dart';
import 'package:talk/pages/my/user_use_auth.dart';

import '../../routers/i_router.dart';
import '../device/device_details_page.dart';
import '../tabs/user.dart';



class XUserRouter implements IRouterProvider{

  static String userPage = '/user';
  static String userInfoPage = '/device/userInfoPage';
  static String userAbout = '/my/userAbout';
  static String userUseAuth = '/my/userUseAuth';
  static String userHideAuth = '/my/userHideAuth';
  static String userSystem = '/my/userSystem';


  @override
  void initRouter(FluroRouter router) {
    router.define(userPage, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {

      return UserPage();
    }));


    router.define(userInfoPage, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {
      final String? IdStr = params['userId']?.first;
      final int userId = int.tryParse(IdStr ?? '0') ?? 0;

      //传递device信息
      final String? JsonStr = params['userModel']?.first;
      UserModel? userModel = UserModel.fromJson(json.decode(JsonStr!));

      return UserInfoPage(userId: userId, userModel: userModel);
    }));




    router.define(userAbout, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {

      return UserAboutPage();
    }));


    router.define(userHideAuth, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {

      return UserHideAuthPage();
    }));



    router.define(userUseAuth, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {

      return UserUseAuthPage();
    }));



    router.define(userSystem, handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {

      return UserSystemPage();
    }));






  }




}





